import { WebSocketHelper } from "./WebSocketHelper";
import { AcceptMsgTemplate } from "./Entity/AcceptMsgTemplate/AcceptMsgTemplate";



// let MyWebSocket = uni ? UniWebScoket : WebSocket;

var ws = new WebSocketHelper({
    uuid: '123',
    projectToken: '123123',
    parameter: JSON.stringify({ userNmae: '消息二号', age: 25 }),
    url: 'http://www.baidu.com'
}, WebSocket);


ws.onopen(() => {
    console.log("onopen")
});

ws.onmessage((e) => {
    let msg: AcceptMsgTemplate = JSON.parse(e.data);
    console.log(msg)
    console.log(e.type)
});


document.getElementById("send").onclick = function(){
    ws.send({
        "Content": "上看兑换方式的",
        "MessageKey": "1",
        "MessageType": 0,
        "Parameter": "{type:'text',length:7}"
    }, function(e) {
        console.log(e)
    }, function(e) {
        console.log(e)
    });
}